package common;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import wrapper.IFieldWrapper;

/**
 * @author Or Kaplan
 *	a wrapper for a table structure
 */
public class RelationTable {
	
	/**
	 * @author Or Kaplan
	 * defines the various table types
	 */
	public enum TableType
	{
		/**
		 * the main table
		 */
		CharacterTable,
		/**
		 * the attribute table
		 */
		AttributeTable,
		/**
		 * many to many connecting table
		 */
		ManyToManyTable
	}
	
	/**
	 * construct a relation table
	 * @param tableName
	 * @param type
	 * @param fileName
	 * @param fields
	 * @param parent
	 */
	public RelationTable(String tableName, TableType type, String fileName, IFieldWrapper[] fields, RelationTable parent)
	{
		this.tableName = tableName;
		this.type = type;
		this.fileName = fileName;
		this.fields = new ArrayList<IFieldWrapper>();
		this.fields.addAll(Arrays.asList(fields));
		this.parent = parent;
	}
	
	private String tableName;
	private TableType type;
	private String fileName;
	private List<IFieldWrapper> fields;
	private RelationTable parent;
	
	public String getTableName() {
		return this.tableName;
	}
	
	public TableType getType() {
		return this.type;
	}
	
	public String getFileName() {
		return this.fileName;
	}
	
	public List<IFieldWrapper> getFields() {
		return this.fields;
	}
	
	public RelationTable getParentTable()
	{
		return this.parent;
	}
}
